# For more information about using CMake with Android Studio, read the
# documentation: https://d.android.com/studio/projects/add-native-code.html.
# For more examples on how to use CMake, see https://github.com/android/ndk-samples.

# Sets the minimum CMake version required for this project.
cmake_minimum_required(VERSION 3.22.1)

# 设置cpp编码标准 c++17
set(CMAKE_CXX_STANDARD 17)
set(CMAKE_CXX_STANDARD_REQUIRED ON)
set(CMAKE_CXX_EXTENSIONS OFF)

project("hellovideocache")

set(3rd_part ${CMAKE_CURRENT_SOURCE_DIR}/3rdpart/android)

# 设置 openssl 目录位置
set(openssl ${3rd_part}/openssl)
include_directories(${openssl}/${ANDROID_ABI}/include) # 添加头文件
# 添加动态库和头文件依赖
add_library(crypto STATIC IMPORTED)
set_target_properties(
        crypto
        PROPERTIES
        IMPORTED_LOCATION
        ${openssl}/${ANDROID_ABI}/lib/libcrypto.a
)
add_library(ssl STATIC IMPORTED)
set_target_properties(
        ssl
        PROPERTIES
        IMPORTED_LOCATION
        ${openssl}/${ANDROID_ABI}/lib/libssl.a
)

# 设置 curl 目录位置
set(curl ${3rd_part}/curl)
include_directories(${curl}/${ANDROID_ABI}/include) # 添加头文件
# 添加动态库和头文件依赖
add_library(curl STATIC IMPORTED)
set_target_properties(
        curl
        PROPERTIES
        IMPORTED_LOCATION
        ${curl}/${ANDROID_ABI}/lib/libcurl.a
)

add_library(${CMAKE_PROJECT_NAME} SHARED
        # List C/C++ source files with relative paths to this CMakeLists.txt.
)

# - - - - - - - - - - - - - - - - Framework模块 - - - - - - - - - - - - - - - -
# 添加头文件 简化 #include "framework/xxx/xxx.hpp"
include_directories(framework/../)

# framework所有模块
add_subdirectory(framework)


# - - - - - - - - - - - - - - - - 平台侧实现 - - - - - - - - - - - - - - - -
# JNI桥代码部分
add_subdirectory(jni)

# Specifies libraries CMake should link to your target library. You
# can link libraries from various origins, such as libraries defined in this
# build script, prebuilt third-party libraries, or Android system libraries.
target_link_libraries(${CMAKE_PROJECT_NAME}
        # List libraries link to the target library
        curl
        ssl
        crypto
        android
        log
        m
        z
)